package com.cho.core.run;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

import com.cho.core.ExcelCore;
import com.cho.core.RegCore;
import com.cho.core.db.dao.TableCreate;
import com.cho.core.db.dao.TableDao;
import com.cho.core.vo.ProjectVo;
import com.cho.core.vo.TableVo;

public class RunConsole {

	private Logger logger =  Logger.getLogger(this.getClass());
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ProjectVo projectVo = new ProjectVo();
		Properties properties = new Properties();
		try {
			properties.load(new FileInputStream("main.properties"));
			projectVo.setProjectName(properties.getProperty("PROJECT_NAME"));
			projectVo.setProjectDirectory(properties.getProperty("SOURCE_DIRECTORY"));
			//properties.list(System.out);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			TableCreate.runTableCreate();
			TableDao.deleteProjectInfo(projectVo.getProjectName());
			TableDao.deleteFileList(projectVo.getProjectName());
			TableDao.deleteTableList(projectVo.getProjectName());
			
			TableDao.insertProjectInfo(projectVo);
			RegCore c = new RegCore();
		
			c.readFolder(projectVo, new File(projectVo.getProjectDirectory()));
			
			ExcelCore excelCore = new ExcelCore();
			excelCore.makeExcel(new TableVo(projectVo.getProjectName()));
			} catch (Exception e) {
				e.printStackTrace();
			}		
	}

}
